package route

import (
	// m "git.llsapp.com/zhenghe/pkg/http/middleware"
	"github.com/gin-gonic/gin"
	"kpt-dtm/http/api"
	"kpt-dtm/http/api/dtm"
)

func AppAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
	return func(s *gin.Engine) {
		for _, opt := range opts {
			opt(s)
		}
		// Not Found
		s.NoRoute(api.Handle404)
		// Health Check
		s.GET("/check", api.Health)

		// newRoute API 组
		newRoute := authRouteGroup(s, "/api/v1/new")
		newRoute.GET("/hello", api.Hello)
		newRoute.GET("/dtm/:path", dtm.Dtm)
		newRoute.GET("/yyn/:path", dtm.Yyn)

		oldRoute := authRouteGroup(s, "/api/v1/old")
		oldRoute.GET("/auth/:id", api.Auth)
		oldRoute.POST("/test", api.Test)
	}
}

func authRouteGroup(s *gin.Engine, relativePath string) *gin.RouterGroup {
	group := s.Group(relativePath)
	// group.Use(middleware.Auth(), m.UserKitMiddleware())
	return group
}
